<?php

namespace App;

use App\Extend\Tools;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Member
 *
 * @property int $id
 * @property string $name
 * @property string $origin 籍贯
 * @property int|null $sex 性别
 * @property string|null $hope_city 期望工作城市
 * @property float|null $lng 精度
 * @property float|null $lat 维度
 * @property string|null $provice 省
 * @property string|null $city 市
 * @property string|null $area 区
 * @property string|null $road 街道
 * @property string|null $street 详细地址
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @property int|null $age 年龄
 * @property string|null $card 身份证
 * @property string|null $bank 银行卡号
 * @property string|null $bank_type 开户银行类型
 * @property int|null $craftmans 所属班组
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereAge($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereArea($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereBank($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereBankType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereCard($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereCity($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereCraftmans($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereHopeCity($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereLat($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereLng($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereOrigin($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereProvice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereRoad($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereSex($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereStreet($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property string|null $province 省
 * @property array $images
 * @property string|null $phone
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereImages($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member wherePhone($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Member whereProvince($value)
 * @property-read mixed $mask_phone
 */
class Member extends Model
{
    protected $guarded = [];
    protected $casts = [
        'images' => 'array'
    ];
    protected $appends = ['mask_phone'];
    public function getCityAttribute($value){
        return Area::whereId($value)->first();
    }

    public function getMaskPhoneAttribute()
    {
        return Tools::getMaskPhone($this->attributes['phone']);
    }

    public function craftsman(){
        return $this->belongsTo('App\Craftsman','craftmans','id');
    }
}
